package com.tiancheng.trade.commom.core.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

/**
 * 清分周期类型
 *
 * @Date 2024/11/5
 * @Author DCH
 */
@Getter
@AllArgsConstructor
public enum ClearingCycleModeEnum {
    DATE("1", "按天"),
    MONTH("2", "按月"),
    ;
    private String code;
    private String desc;

    public static String getDesc(String code) {
        Optional<ClearingCycleModeEnum> found = Arrays.stream(ClearingCycleModeEnum.values()).filter(c -> c.code.equals(code)).findFirst();
        if (found.isPresent()) {
            return found.get().getDesc();
        }
        return "";
    }
}
